package com.topscore.uke.mvp.model;

import com.topscore.uke.entities.MemberCommentsInfo;
import com.topscore.uke.mvp.contractors.GetMemberCommentsContractor;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.network.request.GetMemberCommentsRequest;
import com.topscore.uke.network.retrofit.HandleErrorSubscriber;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class GetMemberCommentsModel implements GetMemberCommentsContractor.Model{
    private CallBack mCallBack;

    public GetMemberCommentsModel(CallBack callBack) {
        this.mCallBack = callBack;
    }

    @Override
    public void getComments(GetMemberCommentsRequest request) {
        mService.getMemberComments(request)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .unsubscribeOn(Schedulers.io())
                .subscribe(new HandleErrorSubscriber<BaseResponse<MemberCommentsInfo>>(mCallBack) {
                    @Override
                    public void onSuccess(BaseResponse<MemberCommentsInfo> response) {
                        mCallBack.onSuccess(response);
                    }
                });
    }
}
